//package com.ctsi.security.controller;
//
//import com.ctsi.commons.util.response.Page;
//import com.ctsi.commons.util.response.PageUtil;
//import com.ctsi.security.PermissionSer;
//import com.ctsi.security.PermissionTypeSer;
//import com.ctsi.security.domain.Permission;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;
//
//
//public class PermissionController extends BaseControl {
//	private PermissionTypeSer permissionTypeService;
//	private PermissionSer permissionService;
//	/** *********************系统功能CRUD***************start********************************** */
//	// 查看系统功能
//	public ModelAndView viewPermission(HttpServletRequest request,
//			HttpServletResponse response) {
//		return new ModelAndView("security/permission/permission");
//	}
//
//	// 查询系统功能数据
//	public ModelAndView permissionPage(HttpServletRequest request,
//			HttpServletResponse response) {
//		int skipResults = 0;
//		int pageSize = Page.DEFAULT_PAGE_SIZE;
//		String start = request.getParameter("start");
//		String limit = request.getParameter("limit");
//		if (limit != null && !limit.trim().equals("")) {
//			pageSize = Integer.parseInt(limit);
//		}
//		if (start != null && !start.trim().equals(""))
//			skipResults = Integer.parseInt(start);
//		Page<Permission> page = permissionService.queryPermission(pageSize, skipResults);
//		PageUtil<Permission> out = new PageUtil<Permission>(page);
//		super.outJson(out, response);
//		return null;
//	}
//
//	// 打开添加系统功能
//	public ModelAndView addPermission(HttpServletRequest request,
//			HttpServletResponse response) {
//		// 资源类型下拉菜单
//		String permissionType = permissionTypeService.findPermissionType();
//		request.setAttribute("permissionType", permissionType);
//		return new ModelAndView("security/permission/addPermission");
//	}
//	//保存功能
//	public ModelAndView savePermission(HttpServletRequest request,
//			HttpServletResponse response) {
//		return saveOrUpdatePermission(request,response);
//	}
//	//更新系统功能
//	public ModelAndView updatePermission(HttpServletRequest request,
//			HttpServletResponse response) {
//		return saveOrUpdatePermission(request,response);
//	}
//
//	// 保存和更新系统功能
//	public ModelAndView saveOrUpdatePermission(HttpServletRequest request,
//			HttpServletResponse response) {
//		String id = request.getParameter("ID");
//		id = id == null ? "" : id;
//		String permissionId = request.getParameter("permissionId");
//		permissionId = permissionId == null ? "" : permissionId;
//		String permissionName = request.getParameter("permissionName");
//		permissionName = permissionName == null ? "" : permissionName;
//		String permissionTypeId = request.getParameter("permissionTypeId");
//		permissionTypeId = permissionTypeId == null ? "" : permissionTypeId;
//		String objectDataId = request.getParameter("objectDataId");
//		objectDataId = objectDataId == null ? "" : objectDataId;
//		String description = request.getParameter("description");
//		description = description == null ? "" : description;
//		Permission permission = new Permission();
//		permission.setId(id);
//		permission.setPermissionId(permissionId);
//		permission.setPermissionName(permissionName);
//		permission.setPermissionTypeId(permissionTypeId);
//		permission.setDataObject(objectDataId);
//		permission.setDescription(description);
//		if (id.equals("")) {
//			if (permissionService.valPermissionId(permissionId)) {
//				super.SetErrMsg(request, "数据库中已存在该ID，请重新填写!");
//				return new ModelAndView("security/permission/addPermission");
//			} else {
//				permissionService.savePermission(permission);
//			}
//		} else {
//			permissionService.updatePermission(permission);
//		}
//		super.setReturnMsg(request, "保存成功");
//		request.setAttribute("permission", permission);
//		// 资源类型下拉菜单
//		String permissionType = permissionTypeService.findPermissionType();
//		request.setAttribute("permissionType", permissionType);
//		return new ModelAndView("security/permission/editPermission");
//	}
//
//	// 打开修改页面
//	public ModelAndView editPermission(HttpServletRequest request,
//			HttpServletResponse response) {
//		String ID = request.getParameter("ID");
//		ID = ID == null ? "" : ID;
//		Permission permission = null;
//		List<Permission> listPermission = permissionService.findPermission(
//				new String[] { "ID" }, new Object[] { ID });
//		if (listPermission.size() > 0) {
//			permission = listPermission.get(0);
//		} else {
//			permission = new Permission();
//		}
//		request.setAttribute("permission", permission);
//		// 资源类型下拉菜单
//		String permissionType = permissionTypeService.findPermissionType();
//		request.setAttribute("permissionType", permissionType);
//		return new ModelAndView("security/permission/editPermission");
//	}
//
//	// 删除系统功能
//	public ModelAndView delPermission(HttpServletRequest request,
//			HttpServletResponse response) {
//		String IDS = request.getParameter("IDS");
//		String permissionIds=request.getParameter("permissionIds");
//		String[] arrayId = IDS.substring(0, IDS.lastIndexOf(",")).split(",");
//		String[] arrayPermissionId = permissionIds.substring(0, permissionIds.lastIndexOf(",")).split(",");
//		for (int i = 0; i < arrayId.length; i++) {
//			permissionService.removePermission(arrayId[i],arrayPermissionId[i]);
//		}
//		return null;
//	}
//	// 查看功能明细
//	public ModelAndView viewPermInfo(HttpServletRequest request,
//			HttpServletResponse response) {
//		return new ModelAndView("security/permission/viewInfo");
//	}
//
//	public void setPermissionTypeService(PermissionTypeSer permissionTypeService) {
//		this.permissionTypeService = permissionTypeService;
//	}
//
//	public void setPermissionService(PermissionSer permissionService) {
//		this.permissionService = permissionService;
//	}
//
//
//
//	/** *********************系统功能CRUD***************end************************************ */
//}
